Fix JSHint issues and unit test in phantomJS