Add functional test for loop unwinding