set document's childNodes property before calling its appendChild method...

... in createDocument