By Andrew Ackerman and Jeffrey Sparshott Of DOW JONES NEWSWIRES WASHINGTON -(Dow Jones)- The U.S. government's emergency programs that helped steady the financial system starting in 2008 are expected to turn an overall profit of nearly $24 billion, the Treasury Department said in a new analysis Wednesday. Treasury officials also said they have now generated a profit from the Troubled Asset Relief Program's loans to banks after three financial institutions repaid a total of $7.4 billion in TARP funds Wednesday. The banks were SunTrust Banks Inc. (STI), of Atlanta; KeyCorp (KEY), of Cleveland; and Financial Institutions Inc. (FISI), of Warsaw, N.Y. Treasury said TARP bank programs are now "in the black" by $6 billion. The federal government initially spent $245 billion to assist troubled banks in the U.S., and now has $251 billion in total repayments, dividends, interest and other income. "While our overriding objective with TARP was to break the back of the financial crisis and save American jobs, the fact that our investment in banks has also delivered a significant profit for taxpayers is a welcome development," Treasury Secretary Tim Geithner said. Treasury expects to eventually turn a $20 billion profit on the nation's troubled banks from the TARP program alone. Still, the Congressional Budget Office Tuesday trimmed its estimate on the cost of the overall Troubled Asset Relief Program to $19 billion. That's well down from an initial estimate of $356 billion, but continues to reflect losses on the bailout of American International Group Inc. (AIG), aid to the automotive industry, and grant programs aimed at avoiding foreclosures. And results remain uneven across the banking sector. Larger institutions are repaying government funds, but scores of smaller banks have missed various payments. Meanwhile, Treasury's overall $23.6 billion profit estimate for all emergency lending programs was announced in a blog post by Timothy Massad, acting assistant secretary for financial stability. It does not include the roughly $800 billion in stimulus funds authorized in 2009. The largest profits stemmed from the Federal Reserve's emergency lending programs, which generated $110.0 billion, Treasury said. Those offset a projected $73 billion loss in money spent to stabilize mortgage giants Fannie Mae (FNMA) and Freddie Mac (FMCC). Rescuing the two companies has cost taxpayers $134 billion to date, but that spending is expected to be offset by dividend payments over the next decade. The new Treasury analysis came on the same day Massad sparred with a departing federal bailout watchdog over the legacy of TARP at a congressional hearing. On his final day on the job, Neil Barofsky, the special inspector general for TARP, warned that the same "too big to fail" firms that nearly brought down the financial system in 2008 have become bigger and more interconnected and continue to maintain an unfair advantage over small competitors. "TARP's most significant legacy may be the exacerbation of the problems posed by 'too big to fail,' particularly given the manner in which Treasury executed the bailout," Barofsky said. He noted that the bailout largely spared "executives, shareholders, creditors and counterparties, reinforcing that not only would the government bail out the largest institutions, but would do so in a manner that would do little harm to the responsible stakeholders." But Massad, who testified later at the same hearing, rejected the idea that TARP's main legacy was to perpetuate the "too big to fail" problem. "TARP was necessary to respond to the worst financial crisis we faced in decades," he said in his remarks. "Its most significant legacy is that it, combined with a variety of other government actions, helped save our economy from a catastrophic collapse and may have helped prevent a second Great Depression." -By Andrew Ackerman and Jeffrey Sparshott; Dow Jones Newswires; 202-569-8390; firstname.lastname@example.org --Alan Zibel contributed to this report.