PhantomJS compatibility fixes.

Fixes #109.

Change-Id: I8423290b5cbd453226d3ba2d269a4593d3c5ad39