Refactored based on jslint output, added a simple working unit test