Remove use of deprecated APIs

Also, add a spec.
Why not use `atom.workspace.getActiveTextEditor()`?