Add core.UnitTest.createXmlDocument, to reduce duplicated code

Follow-up from discussion in #532