bit of cleanup

while (true) is better than for (;;)
Removed unread endIndex
Removed unread startIndex
Refactored out helper methods
wrap lines
Moved method back to where it was

just down a few lines
Improved test comment