fix overflow in test for iteration end condition