Add unit tests, fix jshint errors