Fixed code generation for if expressions

When generating the test clause, place allocations above the if, since they cannot go within the if statement itself.