text_editor specs and refactoring