         self.wait(for: [expectation], timeout: .zero)
         // -> Waiting with zero timeout can be failed when the closure is performed not immediately but in another runloop.
         
-        observer.cancel()
+        self.observer = nil
         UserDefaults.standard[Self.key] = false
     }
     

    
    private static let key = DefaultKey<Bool>("TestKey")
    
    
    override class func tearDown() {
        

        
        UserDefaults.standard[Self.key] = false
        
        self.observer = UserDefaults.standard.observe(key: Self.key) { (value) in
            XCTAssertTrue(value!)
            XCTAssertEqual(OperationQueue.current, .main)
            
