Fixed jshint errors and added test suggest by AndyP