more tests for loops and some cleanups