Corrections for PR comments: reset the flag after test and extract repetitions