Update tests from foreach to iterator