Fixed issues pointed out by Ms2ger & Travis CI

On Travis CI log [1], 4 content tests failed:
servo/src/test/content/test_document_getElementById.html
servo/src/test/content/test_document_importNode.html
servo/src/test/content/test_parentNode_querySelector.html
servo/src/test/content/test_parentNode_querySelectorAll.html

This was caused by a missing check if the tree is/was in Document before
registering/unregistering a named element based on id.

[1] https://travis-ci.org/mozilla/servo/jobs/29916616