fix possible infinite loop in test