fixes for newline
Updates tests for JS and fixes code style, and refactoring