refactoring js, rspec