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

This passes the tests but I'm sure there's a better way of handling this. Let me know how it could be improved.