       return session.deferredDataTask(with: url)
     }()
 
-    usleep(1000)
+    deferred.urlSessionTask.cancel()
 
     do {
       let _ = try deferred.get()
       XCTFail("succeeded incorrectly")
     }
     catch let error as URLError {
-      XCTAssertEqual(error.code, .cannotConnectToHost)
+      XCTAssertEqual(error.code, .cancelled)
     }
 
     let canceled = deferred.cancel()


  func testData_DoubleCancellation() throws
  {
    let deferred: Deferred<(Data, HTTPURLResponse)> = {
      let url = URL(string: "http://127.0.0.1:65521/image.jpg")!
      let session = URLSession(configuration: .default)
      defer { session.finishTasksAndInvalidate() }

  }



  func testDownload_NotFound() throws
  {
