Use while instead of for
Add another test for 100% coverage