             XCTAssertNil(timeoutError)
 
             // Sanity it's actually mocked
-            XCTAssertEqual(delegate.dataKeyedByTask[task1.taskIdentifier], body)
+            XCTAssertEqual(delegate.dataKeyedByTaskIdentifier[task1.taskIdentifier], body)
             
             // Check the delay
             let interval = -start.timeIntervalSinceNow

        self.waitForExpectationsWithTimeout(1) { timeoutError in
            XCTAssertNil(timeoutError)
            
            XCTAssertEqual(delegate.dataKeyedByTask[task.taskIdentifier], body)
            guard let response = delegate.response as? NSHTTPURLResponse else {
                XCTFail("Response isn't the correct type")
                return
            }

private class SessionTestDelegate: NSObject, NSURLSessionDataDelegate {
    var expectations: [XCTestExpectation]
    
    var dataKeyedByTaskIdentifier : [Int : NSMutableData] = [:]
    var responseKeyedByTaskIdentifier : [Int : NSURLResponse] = [:]
    
    init(expectations: [XCTestExpectation]) {
        self.expectations = expectations
    }
    
    @objc func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: (NSURLSessionResponseDisposition) -> Void) {
        self.responseKeyedByTaskIdentifier[dataTask.taskIdentifier] = response
    }
    
    @objc func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData recievedData: NSData) {
        var data = dataKeyedByTaskIdentifier[dataTask.taskIdentifier]
        
        if data == nil {
            data = NSMutableData()
            dataKeyedByTaskIdentifier[dataTask.taskIdentifier] = data
        }
        
        data!.appendData(recievedData)
