         group.wait()
         XCTAssert(sent)
         
+        group.enter()
+        
         eventDispatcher?.setTimer()
         
-        sleep(4)
+        DispatchQueue.global(qos: .background).async {
+            group.leave()
+        }
+        group.wait()
         
         // we are on the main thread and set timer on async main thread
         // so, must be nil here

        eventDispatcher = DefaultEventDispatcher( backingStore: .file)
        let pEventD:OPTEventDispatcher = eventDispatcher!
        eventDispatcher?.timerInterval = 1
        let group = DispatchGroup()
        let enter = { () in
            group.enter()
        }
        let wait = {() in
            self.eventDispatcher?.dispatcher.async {
                group.leave()
            }
            
            group.wait()
        }

        enter()
        
        pEventD.flushEvents()
        
        wait()
        
        enter()
        
        pEventD.dispatchEvent(event: EventForDispatch(body: Data())) { (result) -> (Void) in
            
        }

        wait()
        
        XCTAssert(eventDispatcher?.dataStore.count == 1)
        
        enter()
        
        eventDispatcher?.flushEvents()
        
        wait()
        
        XCTAssert(eventDispatcher?.dataStore.count == 0)

        eventDispatcher = DefaultEventDispatcher( backingStore: .userDefaults)
        let pEventD:OPTEventDispatcher = eventDispatcher!
        eventDispatcher?.timerInterval = 1
        let wait = {() in
            self.eventDispatcher?.dispatcher.sync {
            }
        }

        pEventD.flushEvents()
        wait()
        
        pEventD.dispatchEvent(event: EventForDispatch(body: Data())) { (result) -> (Void) in
            
        }
        wait()
        
        XCTAssert(eventDispatcher?.dataStore.count == 1)
        
        eventDispatcher?.flushEvents()
        wait()
        
        XCTAssert(eventDispatcher?.dataStore.count == 0)
