tests: Avoid infinite loop in test.