Good catch, fixed and updated the unit tests so they would have caught this.

Also your version of the loop is better. I used it, but I didn't give you any credit in the comments, sucker!