Change iteration order to improve perf slightly; cleanup Test.java