Adding unit tests and jshint fixes