corrected potential infinite loop in some tests