refactor javascripts, start testing with Jasmine