         XCTAssertNil(db.document(withID: "doc"))
     }
     
-    func testConflictHandlerDeletedLocalWins() throws {
-        let doc = MutableDocument(id: "doc")
-        doc.setString("Tiger", forKey: "species")
-        try db.saveDocument(doc)
-        
-        let target = DatabaseEndpoint(database: otherDB)
-        var config = self.config(target: target, type: .push, continuous: false)
-        run(config: config, expectedError: nil)
-        
-        // make changes to both documents from db and otherDB
-        try db.deleteDocument(db.document(withID: "doc")!)
-        
-        let doc2 = otherDB.document(withID: "doc")!.toMutable()
-        doc2.setString("striped", forKey: "pattern")
-        try otherDB.saveDocument(doc2)
-        
-        // Pull:
-        config = self.config(target: target, type: .pull, continuous: false)
+    func testConflictResolverDeletedLocalWins() throws {
+        let remoteData = ["key2": "value2"]
+        try makeConflict(forID: "doc", withLocal: nil, withRemote: remoteData)
+        
+        let config = getConfig(.pull)
         let resolver = TestConflictResolver() { (conflict) -> Document? in
+            XCTAssertNil(conflict.localDocument)
+            XCTAssertNotNil(conflict.remoteDocument)
             return nil
         }
         config.conflictResolver = resolver

        XCTAssertNil(db.document(withID: "doc"))
    }
    
    func testConflictHandlerDeletedRemoteWins() throws {
        let doc = MutableDocument(id: "doc")
        doc.setString("Tiger", forKey: "species")
        try db.saveDocument(doc)
        
        let target = DatabaseEndpoint(database: otherDB)
        var config = self.config(target: target, type: .push, continuous: false)
        run(config: config, expectedError: nil)
        
        // make changes to both documents from db and otherDB
        let doc1 = db.document(withID: "doc")!.toMutable()
        doc1.setString("Hobbes", forKey: "name")
        try db.saveDocument(doc1)
        
        try otherDB.deleteDocument(otherDB.document(withID: "doc")!)
        
        // Pull:
        config = self.config(target: target, type: .pull, continuous: false)
        let resolver = TestConflictResolver() { (conflict) -> Document? in
            return nil
        }
        config.conflictResolver = resolver

        config.conflictResolver = resolver
        var token: ListenerToken!
        var replicator: Replicator!
        var error: NSError!
        
        ignoreException {
            self.run(config: config, reset: false, expectedError: nil, onReplicatorReady: {(repl) in
                replicator = repl
                token = repl.addDocumentReplicationListener({ (docRepl) in
                    if let err = docRepl.documents.first?.error as NSError? {
                        error = err
                    }
                })
            })
        }
        XCTAssertNotNil(error)
        XCTAssertEqual(error.code, CBLErrorConflict)
        XCTAssertEqual(error.domain, CBLErrorDomain)
        
        replicator.removeChangeListener(withToken: token)
        resolver = TestConflictResolver() { (conflict) -> Document? in
            return conflict.remoteDocument
        }
        config.conflictResolver = resolver
        run(config: config, expectedError: nil)
        XCTAssert(db.document(withID: docID)!.toDictionary() == remoteData)
    }
    
    func testConflictResolverThrowingException() throws {
        let docID = "doc"
        let localData = ["key1": "value1"]
        let remoteData = ["key2": "value2"]
        let config = getConfig(.pull)
        var resolver: TestConflictResolver!
        
        try makeConflict(forID: docID, withLocal: localData, withRemote: remoteData)
        resolver = TestConflictResolver() { (conflict) -> Document? in
            NSException(name: .internalInconsistencyException,
                        reason: "some exception happened inside custom conflict resolution",
                        userInfo: nil).raise()
            return nil
        }
        config.conflictResolver = resolver
        var token: ListenerToken!
        var replicator: Replicator!
        var error: NSError?
        
        ignoreException {
