this is important when running a test with --loop (cherry picked from commit fc18f16260d15b3584d92f73cebafa3a552e2686)