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

        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()
        UserDefaults.standard[Self.key] = false
    }
    

    
    private static let key = DefaultKey<Bool>("TestKey")
    
    private var observer: UserDefaultsObservation?
    
    
    override class func tearDown() {
        
