             expect(tableEditor).toBeDefined()
 
           describe 'when modified and saved', ->
-            spy = null
             beforeEach ->
-              spy = jasmine.createSpy('did-save')
-              tableEditor.onDidChangeScreenRows(spy)
-
-              tableEditor.addRow ['Bill', 45, 'male']
-              tableEditor.addRow ['Bonnie', 42, 'female']
-
-              waitsFor -> spy.callCount > 0
-
-              runs ->
-                spy = jasmine.createSpy('did-save')
-                tableEditor.onDidSave(spy)
-
-                tableEditor.save()
-
-              waitsFor -> spy.callCount > 0
-
-              waitsFor sleep WRITE_TIMEOUT
-
-            it 'save the new csv content on disk', ->
-              content = fs.readFileSync(csvDest)
-
-              expect(String(content)).toEqual("""
+              modifyAndSave ->
+                tableEditor.addRow ['Bill', 45, 'male']
+                tableEditor.addRow ['Bonnie', 42, 'female']
+
+            it 'save the new csv content on disk', ->
+              expect(savedContent).toEqual("""
               name;age;gender
               Jane;32;female
               John;30;male

            expect(tableEditor.getScreenRowCount()).toEqual(2)

          describe 'when modified and saved', ->
            spy = null
            beforeEach ->
              spy = jasmine.createSpy('did-save')
              tableEditor.onDidChangeScreenRows(spy)

              tableEditor.addRow ['Bill', 45, 'male']
              tableEditor.addRow ['Bonnie', 42, 'female']

              waitsFor -> spy.callCount > 0

              runs ->
                spy = jasmine.createSpy('did-save')
                tableEditor.onDidSave(spy)

                tableEditor.save()

              waitsFor -> spy.callCount > 0

              waitsFor sleep WRITE_TIMEOUT

            it 'save the new csv content on disk', ->
              content = fs.readFileSync(csvDest)

              expect(String(content)).toEqual("""
              name,age,gender
              Jane,32,female
              John,30,male

            expect(tableEditor.getScreenRowCount()).toEqual(2)

          describe 'when modified and saved', ->
            beforeEach ->
              modifyAndSave ->
                tableEditor.addRow ['GHI', 56]
                tableEditor.addRow ['JKL', 78]

            it 'save the new csv content on disk', ->
              expect(savedContent).toEqual("ABC,12::DEF,34::GHI,56::JKL,78")

            it 'marks the table editor as saved', ->
              expect(tableEditor.isModified()).toBeFalsy()
              expect(csvEditor.isModified()).toBeFalsy()
