Stop premature integral expansion described in #2708

Add a test for this issue, and tweak the Integral class to properly handle situations where risch returns an Integral.