In a rare case of positive momentum in the beat-up energy sector, U.S. mutual funds have piled into shares of Tesoro Corp and Valero Energy Corp , two independent refinery companies taking advantage of cheap crude prices.

Tesoro and Valero are shining stars in an otherwise gloomy picture of the S&P 500 Energy Sector Index, whose one-year return is minus 21 percent. Shares of Tesoro, the benchmark's top performer during that period, are up 62 percent, followed by those of No. 2 performer Valero, up 40 percent.

Falling oil prices tend to benefit refiners because they purchase crude as a feedstock for their refineries, which churn out valuable fuels such as gasoline and diesel.

But portfolio managers say another reason they are interested in the sector is that the management teams at top U.S. refiners have become disciplined about their capital spending plans and are returning more cash to shareholders.

"The group has found religion, especially with capital deployment," said George Maris, manager of the $2 billion Janus Global Select Fund, which owned $39 million worth of Valero stock at the end of June.

The number of actively managed mutual funds investing in Tesoro and Valero increased by 20 percent and 32 percent, respectively, this year. Fund research firm Lipper Inc said 319 funds currently hold Valero shares and 210 hold Tesoro. And the number of funds holding both companies has increased 31 percent to 151, according to Lipper, a unit of Thomson Reuters.

One notable entrant is Fidelity Investments' $103 billion Contrafund, which has largely avoided oil stocks during the sector's meltdown. But this year, the fund, run by star portfolio manager Will Danoff, has accumulated stakes in Tesoro and Valero worth $93 million and $149 million, respectively, according to end-of-August fund disclosures.

The $4.4 billion MFS Research Fund also initiated a position in Valero, buying about 565,000 shares in June. Analysts at the fund praised management for increasing its dividend, reducing capital expenditure growth and boosting free cash flow, according to fund commentary for investors.

The rosy picture for refiners contrasts with the problems facing exploration and production companies, many of which are struggling to survive low energy prices by selling assets and relying heavily on Wall Street banks for credit.

U.S. crude futures on Oct. 9 traded at $49.57 a barrel , down from more than $107 a barrel in June 2014, amid an overabundance of global supply.

Arthur Barry, portfolio manager of the $1.5 billion Loomis Sayles Value Fund, said he is worried that Valero's outperformance has attracted the fund industry's momentum money - a potential red flag.

"That makes us a little bit nervous," said Barry, whose value fund held about 262,000 Valero shares at the end of August. "When things turn, they'll flee the stock."

U.S. hedge funds have already trimmed some of their holdings in Valero, cutting them to 46.3 million shares from 68.6 million during the first half of 2015, according to data compiled by industry research firm Symmetric.io.