     for key in keys.split('')
       helpers.keydown(key, options)
 
+  text = (text=null)->
+    if text
+      editor.setText(text)
+    else
+      expect(editor.getText())
+
+  cursor = (point=null)->
+    if point
+      editor.setCursorScreenPosition(point)
+    else
+      expect(editor.getCursorScreenPosition())
+
+  register = (name, value)->
+    if value
+      vimState.setRegister(name, value)
+    else
+      expect(vimState.getRegister(name).text)
+
   describe "Repeat", ->
     describe "with operations", ->
       beforeEach ->
-        editor.setText("123456789abc")
-        editor.setCursorScreenPosition([0, 0])
+        text "123456789abc"
+        cursor [0, 0]
 
       it "repeats N times", ->
         keystroke '3x'
-        expect(editor.getText()).toBe '456789abc'
+        text().toBe '456789abc'
 
       it "repeats NN times", ->
         keystroke '10x'
-        expect(editor.getText()).toBe 'bc'
+        text().toBe 'bc'
 
     describe "with motions", ->
       beforeEach ->
-        editor.setText('one two three')
-        editor.setCursorScreenPosition([0, 0])
+        text 'one two three'
+        cursor [0, 0]
 
       it "repeats N times", ->
         keystroke 'd2w'
-        expect(editor.getText()).toBe 'three'
+        text().toBe 'three'
 
     describe "in visual mode", ->
       beforeEach ->
-        editor.setText('one two three')
-        editor.setCursorScreenPosition([0, 0])
+        text 'one two three'
+        cursor [0, 0]
 
       it "repeats movements in visual mode", ->
         keystroke 'v2w'
-        expect(editor.getCursorScreenPosition()).toEqual [0, 9]
+        cursor().toEqual [0, 9]
 
   describe "Register", ->
     describe "the a register", ->
       it "saves a value for future reading", ->
-        vimState.setRegister('a', text: 'new content')
-        expect(vimState.getRegister("a").text).toEqual 'new content'
+        register('a', text: 'new content')
+        register('a').toEqual 'new content'
 
       it "overwrites a value previously in the register", ->
-        vimState.setRegister('a', text: 'content')
-        vimState.setRegister('a', text: 'new content')
-        expect(vimState.getRegister("a").text).toEqual 'new content'
+        register('a', text: 'content')
+        register('a', text: 'new content')
+        register('a').toEqual 'new content'
 
     describe "the B register", ->
       it "saves a value for future reading", ->
-        vimState.setRegister('B', text: 'new content')
-        expect(vimState.getRegister("b").text).toEqual 'new content'
-        expect(vimState.getRegister("B").text).toEqual 'new content'
+        register('B', text: 'new content')
+        register('b').toEqual 'new content'
+        register('B').toEqual 'new content'
 
       it "appends to a value previously in the register", ->
-        vimState.setRegister('b', text: 'content')
-        vimState.setRegister('B', text: 'new content')
-        expect(vimState.getRegister("b").text).toEqual 'contentnew content'
+        register('b', text: 'content')
+        register('B', text: 'new content')
+        register("b").toEqual 'contentnew content'
 
       it "appends linewise to a linewise value previously in the register", ->
-        vimState.setRegister('b', {type: 'linewise', text: 'content\n'})
-        vimState.setRegister('B', text: 'new content')
-        expect(vimState.getRegister("b").text).toEqual 'content\nnew content\n'
+        register('b', {type: 'linewise', text: 'content\n'})
+        register('B', text: 'new content')
+        register('b').toEqual 'content\nnew content\n'
 
       it "appends linewise to a character value previously in the register", ->
-        vimState.setRegister('b', text: 'content')
-        vimState.setRegister('B', {type: 'linewise', text: 'new content\n'})
-        expect(vimState.getRegister("b").text).toEqual 'content\nnew content\n'
+        register('b', text: 'content')
+        register('B', {type: 'linewise', text: 'new content\n'})
+        register("b").toEqual 'content\nnew content\n'
 
 
     describe "the * register", ->
       describe "reading", ->
         it "is the same the system clipboard", ->
-          expect(vimState.getRegister('*').text).toEqual 'initial clipboard content'
+          register('*').toEqual 'initial clipboard content'
           expect(vimState.getRegister('*').type).toEqual 'character'
 
       describe "writing", ->
         beforeEach ->
-          vimState.setRegister('*', text: 'new content')
+          register('*', text: 'new content')
 
         it "overwrites the contents of the system clipboard", ->
           expect(atom.clipboard.read()).toEqual 'new content'

    describe "the _ register", ->
      describe "reading", ->
        it "is always the empty string", ->
          expect(vimState.getRegister("_").text).toEqual ''

      describe "writing", ->
        it "throws away anything written to it", ->
          vimState.setRegister('_', text: 'new content')
          expect(vimState.getRegister("_").text).toEqual ''

    describe "the % register", ->
      beforeEach ->

    describe "the + register", ->
      describe "reading", ->
        it "is the same the system clipboard", ->
          register('*').toEqual 'initial clipboard content'
          expect(vimState.getRegister('*').type).toEqual 'character'

      describe "writing", ->
        beforeEach ->
          register('*', text: 'new content')

        it "overwrites the contents of the system clipboard", ->
          expect(atom.clipboard.read()).toEqual 'new content'
