Fix global leak in PhantomJS
Fix document