Add tests for loops, fix unop codes