Add support for document.toString(), questionably fixes #935