     for i in 0 ..< 10000 {
       dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
         cache.get(urls[i % 50]) {
-          image in
-          XCTAssert(image!.size.width == 200 && image!.size.height == 200 , "Pass")
+          [weak self] image in
+          self?.check(image)
         }
       }
     }

    config.usingDiskCache = false
    config.limitByteSize = 100
    let cache = PIImageCache(config: config)
    let url = NSURL(string: "http://place-hold.it/200x200")!
    var image: UIImage?, result: PIImageCache.Result
    (image, result) = cache.perform(url)
    XCTAssert(result != .MemoryHit, "Pass")
    XCTAssert(image!.size.width == 200 && image!.size.height == 200 , "Pass")
    (image, result) = cache.perform(url)
    XCTAssert(result != .MemoryHit, "Pass")
    XCTAssert(image!.size.width == 200 && image!.size.height == 200 , "Pass")
  }
  
  func testSyncGet() {
    let cache = PIImageCache()
    let url = NSURL(string: "http://place-hold.it/200x200")!
    let image = cache.get(url)!
    XCTAssert(image.size.width == 200 && image.size.height == 200 , "Pass")
  }
  
  func testAsyncGet() {
    let cache = PIImageCache()
    let url = NSURL(string: "http://place-hold.it/200x200")!
    cache.get(url) {
      image in
      XCTAssert(image!.size.width == 200 && image!.size.height == 200 , "Pass")
    }
  }
  
  func testExtension() {
    let url = NSURL(string: "http://place-hold.it/200x200")!
    let cache = PIImageCache()
    let image = url.getImageWithCache(cache)!
    XCTAssert(image.size.width == 200 && image.size.height == 200 , "Pass")
    let image2 = url.getImageWithCache()!
    XCTAssert(image2.size.width == 200 && image2.size.height == 200 , "Pass")
    var imgView = UIImageView()
    imgView.imageOfURL(url, cache: cache) {
      isOK in

    for i in 0 ..< 5 {
      (image, result) = cache.perform(urls[i])
      XCTAssert(result != .MemoryHit, "Pass")
      check(image)
    }
    
    for i in 0 ..< 5 {
      (image, result) = cache.perform(urls[i])
      XCTAssert(result == .MemoryHit, "Pass")
      check(image)
    }

    config.maxMemorySum = 2
