clean up warnings and add tests

Cleans up JSHint warnings and gets rid of the "for...of" syntax.