refactor javascripts, one test is not passed