Refactoring to pass JsLint
Updated unit tests accordingly