               migratedDoc.save (err) =>
                 assert.equal err, null
 
-                PreviouslyUnencryptedModel.findById(@docId).lean().exec (err, migratedDoc) =>
+                PreviouslyUnencryptedModelMigrated.findById(@docId).lean().exec (err, migratedDoc) =>
                   assert.equal err, null
                   assert.notProperty migratedDoc, 'text', 'Should be encrypted in raw db after saved'
                   assert.notProperty migratedDoc, 'bool'

            assert.property migratedDoc, '_ct', 'Should have ciphertext in raw db after migration'


            PreviouslyUnencryptedModel.findById @docId, (err, migratedDoc) =>
              assert.equal err, null, 'There should be no authentication error after migrated'
              assert.propertyVal migratedDoc, 'text', 'Plain'
              assert.propertyVal migratedDoc, 'bool', true

          assert.equal err, null

          # add back in middleware
          PreviouslyUnencryptedSchemaMigrated = mongoose.Schema schemaObject
          PreviouslyUnencryptedSchemaMigrated.plugin encrypt,
            encryptionKey: encryptionKey
            signingKey: signingKey
            _suppressDuplicatePluginError: true # to allow for this test
            collectionId: 'FormerlyPlain'
          PreviouslyUnencryptedModelMigrated = mongoose.model 'FormerlyPlain2', PreviouslyUnencryptedSchemaMigrated, 'formerlyplains'

          PreviouslyUnencryptedModelMigrated.findById(@docId).lean().exec (err, migratedDoc) =>
            assert.equal err, null
            assert.notProperty migratedDoc, 'text', 'Should be encrypted in db after migration'
            assert.notProperty migratedDoc, 'bool'
