 
 class MockCallback {
     var name: String = ""
-    var calls: [Any?] = []
+    var calls: [[String: Any]] = []
     init(name: String) {
         self.name = name
     }
     func call(payload: Any?) -> Void {
         print("calling \(name) with \(payload)")
-        self.calls.append(payload)
+        self.calls.append(payload as! [String: Any])
     }
 }
 

    func testExecutesAllSubscriberCallbacks() {
        dispatcher.register(callbackA.call)
        dispatcher.register(callbackB.call)
        let payload = [:]
        
        dispatcher.dispatch(payload)
        
        XCTAssertEqual(callbackA.calls.count, 1)
//        XCTAssertEqual(callbackA.calls[0]! === payload)

        XCTAssertEqual(callbackB.calls.count, 1)
//        XCTAssert(callbackB.calls[0]! === payload)

        dispatcher.dispatch(payload)
        
        XCTAssertEqual(callbackA.calls.count, 2)
//        XCTAssert(callbackA.calls[1]! === payload)
        
        XCTAssertEqual(callbackB.calls.count, 2)
//        XCTAssert(callbackB.calls[1]! === payload)
    }
    
    func testWaitsForCallbacksRegisteredEarlier() {

        dispatcher.register { (payload) -> Void in
            self.dispatcher.waitFor([tokenA])
            XCTAssertEqual(self.callbackA.calls.count, 1)
            XCTAssertEqual(self.callbackA.calls[0]["test"] as! Int, 1)
            self.callbackB.call(payload)
        }
        
        let payload: [String: Any] = ["test": 1]
        dispatcher.dispatch(payload)
        
        XCTAssertEqual(callbackA.calls.count, 1)
        XCTAssertEqual(callbackA.calls[0]["test"] as! Int, 1)
   
        XCTAssertEqual(callbackB.calls.count, 1)
        XCTAssertEqual(callbackB.calls[0]["test"] as! Int, 1)
    }
    
    func testProperlyUnregistersCallbacks() {
        dispatcher.register(callbackA.call)
        let tokenB = dispatcher.register(callbackB.call)
        let payload: [String: Any] = ["test": 1]
        dispatcher.dispatch(payload)
        
        XCTAssertEqual(callbackA.calls.count, 1)
        XCTAssertEqual(callbackA.calls[0]["test"] as! Int, 1)
        
        XCTAssertEqual(callbackB.calls.count, 1)
        XCTAssertEqual(callbackB.calls[0]["test"] as! Int, 1)
        
        dispatcher.unregister(tokenB)
        dispatcher.dispatch(payload)
        
        XCTAssertEqual(callbackA.calls.count, 2)
        XCTAssertEqual(callbackA.calls[1]["test"] as! Int, 1)
        
        XCTAssertEqual(callbackB.calls.count, 1)
    }
