                 if #available(iOS 10.0, tvOS 10.0, macOS 10.12, *) {
                     dispatchPrecondition(condition: .onQueue(customQueue))
                 }
-                expectation.fulfill()
+                DispatchQueue.main.async {
+                    expectation.fulfill()
+                }
         })
         waitForExpectations(timeout: 5, handler: nil)
     }
     
     func testDefaultOptionCouldApply() {
-        let expectation = self.expectation(description: "running on custom queue")
+        let expectation = self.expectation(description: "Default options")
         let URLString = testKeys[0]
         _ = stubRequest("GET", URLString).andReturn(200)?.withBody(testImageData)
         

    
    func testOriginalImageCouldBeStored() {
        let expectation = self.expectation(description: "waiting for cache finished")
        delay(0.1) {
            let URLString = testKeys[0]
            _ = stubRequest("GET", URLString).andReturn(200)?.withBody(testImageData)
            let url = URL(string: URLString)!
            
            let p = SimpleProcessor()
            let options: KingfisherOptionsInfo = [.processor(p), .cacheOriginalImage]
            self.manager.downloadAndCacheImage(with: url, forKey: URLString, retrieveImageTask: RetrieveImageTask(), progressBlock: nil, completionHandler: {
                (image, error, cacheType, url) in
                delay(0.1) {
                    var imageCached = self.manager.cache.imageCachedType(forKey: URLString, processorIdentifier: p.identifier)
                    var originalCached = self.manager.cache.imageCachedType(forKey: URLString)
                    
                    XCTAssertEqual(imageCached, .memory)
                    XCTAssertEqual(originalCached, .memory)
                    
                    self.manager.cache.clearMemoryCache()
                    
                    imageCached = self.manager.cache.imageCachedType(forKey: URLString, processorIdentifier: p.identifier)
                    originalCached = self.manager.cache.imageCachedType(forKey: URLString)
                    XCTAssertEqual(imageCached, .disk)
                    XCTAssertEqual(originalCached, .disk)
                    
                    expectation.fulfill()
                }
            }, options: options)
            
        }
        self.waitForExpectations(timeout: 5, handler: nil)
    }
    

                if #available(iOS 10.0, tvOS 10.0, macOS 10.12, *) {
                    dispatchPrecondition(condition: .onQueue(customQueue))
                }

                DispatchQueue.main.async {
                    completionExpectation.fulfill()
                }
        })
        waitForExpectations(timeout: 5, handler: nil)
    }
