Refactored perfect game test with for loop