     }
     
     func testDispatcherMethods() {
-        eventDispatcher = DefaultEventDispatcher()
-        let group = DispatchGroup()
-        
-        group.enter()
-        eventDispatcher?.flushEvents()
-        eventDispatcher?.dispatcher.sync {
-            group.leave()
-        }
-        group.wait()
-        
-        group.enter()
+        eventDispatcher = DefaultEventDispatcher(timerInterval: 1)
+        
+        eventDispatcher?.flushEvents()
+        eventDispatcher?.dispatcher.sync {
+        }
         
         eventDispatcher?.dispatchEvent(event: EventForDispatch(body: Data())) { (result) -> (Void) in
         }
         
         eventDispatcher?.dispatcher.sync {
-            group.leave()
-        }
-        
-        group.wait()
+        }
         
         eventDispatcher?.applicationDidBecomeActive()
-
         eventDispatcher?.applicationDidEnterBackground()
         
         XCTAssert(eventDispatcher?.timer.property == nil)
         var sent = false
+        
+        let group = DispatchGroup()
+        
         group.enter()
         
         eventDispatcher?.sendEvent(event: EventForDispatch(body: Data())) { (result) -> (Void) in


    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        let group = DispatchGroup()
        group.enter()
        
        if let dispatcher = eventDispatcher {
            dispatcher.flushEvents()
            dispatcher.dispatcher.sync {
                group.leave()
            }
            group.wait()
        }
        
        eventDispatcher = nil

        group.wait()
        XCTAssert(sent)
        
        group.enter()
        
        eventDispatcher?.setTimer()
        
        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
