         XCTAssertEqual(count2, 0)
     }
     
+    func testCountForEntityInBack() {
+        insertOneItem()
+        
+        let expectation = expectationWithDescription("testCountForEntityInBack")
+        
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
+            let count = self.dbHelper.countForEntity(self.entityName)
+            XCTAssertNotNil(count)
+            XCTAssertEqual(count!, 1)
+            expectation.fulfill()
+        }
+
+        waitForExpectationsWithTimeout(2) { (error) in
+            if let error = error {
+                print("Error: \(error.localizedDescription)")
+            }
+        }
+    }
+    
     func testCountForEntityConcurrent() {
         insertOneItem()
         

        let items = dbHelper.fetchEntity("TestItem")
        XCTAssertNotNil(items)
        XCTAssertTrue(items!.count != 0)
    }
    
    func testFetchOneEntityConcurrent() {

        dbHelper.removeAllEntity("TestItem")
    }
    
    func testRemoveAllEntityInBack() {
        for _ in 0..<3 {
            insertOneItem()
        }
        
        let expectation = expectationWithDescription("testRemoveAllEntityInBack")
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { 
            let result = self.dbHelper.removeAllEntity(self.entityName)
            XCTAssertTrue(result)
            expectation.fulfill()
        }
        
        waitForExpectationsWithTimeout(2) { (error) in
            if let error = error {
                print("wait error: \(error.localizedDescription)")
            }
        }
    }
    
    func testRemoveAllEntityConcurrent() {
        for _ in 0..<3 {
            insertOneItem()
