Fixing bugs with phantomjs dependency, and fixing bugs broken by a foolish last minute refactoring