Fix XML documents in jsdom

If a XML document is detected, don't wrap it in HTML tags.

Fixes #779.
Add test for appending scripts to svg doc
Fix null pointer error with svg documents

This fixes the value documentElement returns when the document is an svg
document (or any other kind of xml document).

jsdom isn't really well equipped to handle non-html documents though.
While the script gets appended, it won't get loaded. To resolve that I
ventured deep into DOM land, however I don't have any clue how this is
supposed to work.
Add missing window.close to tests