Stocks Gain as Yellen Testifies on Monetary Policy, Economy