Tests and refactoring for TextDocumentReader