added unit test, fixed jslint issues