Add regression test for loop splitting bug.
Repair exception handling.