Fixed broken test.

Also made some 'for' loops a bit more Pythonic