               observer?.emit(.MainWindowChanged, forElement: appElement)
             }
 
-            return initializeApp().then { appDelegate -> () in
-              let app = Swindler.Application(delegate: appDelegate)
-              expect(app.mainWindow.value).toEventuallyNot(beNil())
-            }
+            var app: Swindler.Application!
+            waitUntil { done in initializeApp().then { appDelegate -> () in
+              app = Swindler.Application(delegate: appDelegate)
+              done()
+            } }
+            expect(app.mainWindow.value).toEventuallyNot(beNil())
           }
         }
 

              observer.emit(.MainWindowChanged, forElement: windowElement)
            }

            return initializeApp().then { appDelegate -> () in
              let app = Swindler.Application(delegate: appDelegate)
              expect(app.mainWindow.value).toEventuallyNot(beNil())
            }
          }
        }


        }

        context("for an object property") {
          it("is updated correctly") {
            let windowElement = TestWindowElement(forApp: appElement)
            appElement.windows.append(windowElement)
            windowElement.attrs[.Main]    = false
