Bug fix for adding <body> tag when missing

If the document contains children other than <head>, move those into the
new body element before adding it to the document.