Fixes failing unit test when run through phantomjs

Also add 2 new tests