small loop mistake in test code