Update JSCS
Refactor for better testability and initial tests