Remove possibility of infinite loop in tests