refactoring phantomjs unit tests