fixed a loop bound bug in the testing part