Add InvalidDocumentError, future test for it