                 t.column("b", .integer)
             }
             
-            selectionInfo1 = try db.makeSelectStatement("SELECT * FROM table1").selectionInfo
-            selectionInfo2 = try db.makeSelectStatement("SELECT id, a FROM table1").selectionInfo
-            selectionInfo3 = try db.makeSelectStatement("SELECT table1.id, table1.a, table2.a FROM table1 JOIN table2 ON table1.id = table2.id").selectionInfo
-        }
-        
-        var changed1 = false
-        var changed2 = false
-        var changed3 = false
-        
-        selectionInfo1.rx.selection(in: writer).subscribe(onNext: { _ in changed1 = true }).addDisposableTo(disposeBag)
-        selectionInfo2.rx.selection(in: writer).subscribe(onNext: { _ in changed2 = true }).addDisposableTo(disposeBag)
-        selectionInfo3.rx.selection(in: writer).subscribe(onNext: { _ in changed3 = true }).addDisposableTo(disposeBag)
+            try selectionInfos.append(db.makeSelectStatement("SELECT * FROM table1").selectionInfo)
+            try selectionInfos.append(db.makeSelectStatement("SELECT id, a FROM table1").selectionInfo)
+            try selectionInfos.append(db.makeSelectStatement("SELECT table1.id, table1.a, table2.a FROM table1 JOIN table2 ON table1.id = table2.id").selectionInfo)
+        }
+        
+        var changes = selectionInfos.map { _ in false }
+        for (index, selectionInfo) in selectionInfos.enumerated() {
+            selectionInfo.rx
+                .selection(in: writer)
+                .subscribe(onNext: { _ in changes[index] = true })
+                .addDisposableTo(disposeBag)
+        }
         
         // Subscription immediately triggers an event
-        XCTAssertTrue(changed1)
-        XCTAssertTrue(changed2)
-        XCTAssertTrue(changed3)
-        
-        try writer.write { db in
-            func reset() {
-                changed1 = false
-                changed2 = false
-                changed3 = false
-            }
+        XCTAssertEqual(changes, [true, true, true])
+        
+        try writer.write { db in
+            func reset() { changes = changes.map { _ in false } }
             
             // Transaction triggers an event for concerned selection
             reset()
             try db.inTransaction {
                 try db.execute("INSERT INTO table1 (id, a, b) VALUES (NULL, 0, 0)")
-                XCTAssertFalse(changed1)
-                XCTAssertFalse(changed2)
-                XCTAssertFalse(changed3)
+                XCTAssertEqual(changes, [false, false, false])
                 return .commit
             }
-            XCTAssertTrue(changed1)
-            XCTAssertTrue(changed2)
-            XCTAssertTrue(changed3)
+            XCTAssertEqual(changes, [true, true, true])
             
             // Transaction triggers an event for concerned selection
             reset()
             try db.execute("INSERT INTO table2 (id, a, b) VALUES (NULL, 0, 0)")
-            XCTAssertFalse(changed1)
-            XCTAssertFalse(changed2)
-            XCTAssertTrue(changed3)
+            XCTAssertEqual(changes, [false, false, true])
             
             // Transaction triggers an event for concerned selection
             reset()
             try db.execute("UPDATE table1 SET a = 1")
-            XCTAssertTrue(changed1)
-            XCTAssertTrue(changed2)
-            XCTAssertTrue(changed3)
+            XCTAssertEqual(changes, [true, true, true])
             
             // Transaction triggers an event for concerned selection
             reset()
             try db.execute("UPDATE table1 SET b = 1")
-            XCTAssertTrue(changed1)
-            XCTAssertFalse(changed2)
-            XCTAssertFalse(changed3)
+            XCTAssertEqual(changes, [true, false, false])
             
             // Transaction triggers an event for concerned selection
             reset()
             try db.execute("UPDATE table2 SET a = 1")
-            XCTAssertFalse(changed1)
-            XCTAssertFalse(changed2)
-            XCTAssertTrue(changed3)
+            XCTAssertEqual(changes, [false, false, true])
             
             // Transaction triggers an event for concerned selection
             reset()
             try db.execute("UPDATE table2 SET b = 1")
-            XCTAssertFalse(changed1)
-            XCTAssertFalse(changed2)
-            XCTAssertFalse(changed3)
-        }
-    }
-    
-    func testSelectionInfoRxSelection() throws {
-        let testQueue = try TestDatabase { try DatabaseQueue(path: $0) }
-        try testSelectionInfoRxSelection(writer: testQueue.writer)
-        
-        let testPool = try TestDatabase { try DatabasePool(path: $0) }
-        try testSelectionInfoRxSelection(writer: testPool.writer)
+            XCTAssertEqual(changes, [false, false, false])
+        }
+    }
+}
+
+extension ReactiveRequestTests {
+    func testRequestRxSelection() throws {
+        try TestDatabase({ try DatabaseQueue(path: $0) }).test(with: testRequestRxSelection)
+        try TestDatabase({ try DatabasePool(path: $0) }).test(with: testRequestRxSelection)
     }
     
     func testRequestRxSelection(writer: DatabaseWriter) throws {

    override func tearDown() {
        disposeBag = nil
    }
    
    func testSelectionInfoRxSelection(writer: DatabaseWriter) throws {
        var selectionInfo1: SelectStatement.SelectionInfo! = nil
        var selectionInfo2: SelectStatement.SelectionInfo! = nil
        var selectionInfo3: SelectStatement.SelectionInfo! = nil
        
        try writer.write { db in
            try db.create(table: "table1") { t in
                t.column("id", .integer).primaryKey()

            }
        }
        
        let requests = [
            SQLRequest("SELECT * FROM table1"),
            SQLRequest("SELECT id, a FROM table1"),
            SQLRequest("SELECT table1.id, table1.a, table2.a FROM table1 JOIN table2 ON table1.id = table2.id")]
        
        var changes = requests.map { _ in false }
        for (index, request) in requests.enumerated() {
            request.rx
                .selection(in: writer)
                .subscribe(onNext: { _ in changes[index] = true })
                .addDisposableTo(disposeBag)
        }
        
        // Subscription immediately triggers an event
        XCTAssertEqual(changes, [true, true, true])
        
        try writer.write { db in
            func reset() { changes = changes.map { _ in false } }
            
            // Transaction triggers an event for concerned requests
            reset()
            try db.inTransaction {
                try db.execute("INSERT INTO table1 (id, a, b) VALUES (NULL, 0, 0)")
                XCTAssertEqual(changes, [false, false, false])
                return .commit
            }
            XCTAssertEqual(changes, [true, true, true])
            
            // Transaction triggers an event for concerned requests
            reset()
            try db.execute("INSERT INTO table2 (id, a, b) VALUES (NULL, 0, 0)")
            XCTAssertEqual(changes, [false, false, true])
            
            // Transaction triggers an event for concerned requests
            reset()
            try db.execute("UPDATE table1 SET a = 1")
            XCTAssertEqual(changes, [true, true, true])
            
            // Transaction triggers an event for concerned requests
            reset()
            try db.execute("UPDATE table1 SET b = 1")
            XCTAssertEqual(changes, [true, false, false])
            
            // Transaction triggers an event for concerned requests
            reset()
            try db.execute("UPDATE table2 SET a = 1")
            XCTAssertEqual(changes, [false, false, true])
            
            // Transaction triggers an event for concerned requests
            reset()
            try db.execute("UPDATE table2 SET b = 1")
            XCTAssertEqual(changes, [false, false, false])
        }
    }
}

extension ReactiveRequestTests {
    func testRequestRxFetchAll() throws {
        try TestDatabase({ try DatabaseQueue(path: $0) }).test(with: testRequestRxFetchAll)
        try TestDatabase({ try DatabasePool(path: $0) }).test(with: testRequestRxFetchAll)
    }

    func testRequestRxFetchAll(writer: DatabaseWriter) throws {
        try writer.write { db in
            try db.create(table: "persons") { t in
                t.column("id", .integer).primaryKey()
