               windowElement.attrs[.Main]    = true
               appElement.attrs[.MainWindow] = windowElement
               observer.emit(.MainWindowChanged, forElement: windowElement)
+            }
+
+            return initializeApp().then { appDelegate -> () in
+              let app = Swindler.Application(delegate: appDelegate)
+              expect(app.mainWindow.value).toEventuallyNot(beNil())
+            }
+          }
+        }
+
+      }
+
+      context("when a property value changes right after reading it") {
+
+        context("for a regular property") {
+          it("is updated correctly") { () -> Promise<Void> in
+            appElement.attrs[.Frontmost] = false
+
+            var observer: AdversaryObserver?
+            AdversaryObserver.onAddNotification(.ApplicationActivated) { obs in
+              observer = obs
+            }
+            appElement.onFirstAttributeRead(.Frontmost) { _ in
+              appElement.attrs[.Frontmost] = true
+              observer?.emit(.ApplicationActivated, forElement: appElement)
+            }
+
+            return initializeApp().then { appDelegate -> () in
+              let app = Swindler.Application(delegate: appDelegate)
+              expect(app.frontmost.value).toEventually(beTrue())
+            }
+          }
+        }
+
+        context("for an object property") {
+          it("is updated correctly") { () -> Promise<Void> in
+            let windowElement = TestWindowElement(forApp: appElement)
+            appElement.windows.append(windowElement)
+            windowElement.attrs[.Main]    = false
+            appElement.attrs[.MainWindow] = nil
+
+            var observer: AdversaryObserver?
+            AdversaryObserver.onAddNotification(.MainWindowChanged) { obs in
+              observer = obs
+            }
+            appElement.onFirstAttributeRead(.MainWindow) { _ in
+              windowElement.attrs[.Main]    = true
+              appElement.attrs[.MainWindow] = windowElement
+              observer?.emit(.MainWindowChanged, forElement: appElement)
             }
 
             return initializeApp().then { appDelegate -> () in

    }

    describe("AXUIElement notifications") {
      beforeEach { AdversaryObserver.reset() }

      typealias AppDelegate = OSXApplicationDelegate<TestUIElement, TestApplicationElement, AdversaryObserver>
      func initializeApp() -> Promise<AppDelegate> {
        return AppDelegate.initialize(axElement: appElement, notifier: notifier)
      }

      context("when a property value changes right before observing one") {

        context("for a regular property") {
          it("is read correctly") { () -> Promise<Void> in

          it("is updated correctly") { () -> Promise<Void> in
            windowElement.attrs[.Minimized] = false

            var observer: AdversaryObserver?
            AdversaryObserver.onAddNotification(.WindowMiniaturized) { obs in
              observer = obs
            }
            windowElement.onAttributeFirstRead(.Minimized) {
              windowElement.attrs[.Minimized] = true
              observer?.emit(.WindowMiniaturized, forElement: windowElement)
            }

            return initialize().then { winDelegate -> () in
