 
 
     private func checkSites(history: BrowserHistory, urls: [String: String], s: Bool = true) {
-        let expectation = self.expectationWithDescription("Wait for history")
-
-        // Retrieve the entry
-        innerCheckSites(history) { cursor in
-            XCTAssertEqual(cursor.status, CursorStatus.Success, "returned success \(cursor.statusMessage)")
-            XCTAssertEqual(cursor.count, urls.count, "cursor has \(urls.count) entries")
+        // Retrieve the entry.
+        if let cursor = history.getSitesByLastVisit(100).value.successValue {
+            XCTAssertEqual(cursor.status, CursorStatus.Success, "Returned success \(cursor.statusMessage).")
+            XCTAssertEqual(cursor.count, urls.count, "Cursor has \(urls.count) entries.")
 
             for index in 0..<cursor.count {
                 let s = cursor[index]!
-                XCTAssertNotNil(s, "cursor has a site for entry")
+                XCTAssertNotNil(s, "Cursor has a site for entry.")
                 let title = urls[s.url]
-                XCTAssertNotNil(title, "Found right url")
-                XCTAssertEqual(s.title, title!, "Found right title")
-            }
-            expectation.fulfill()
-        }
-
-        self.waitForExpectationsWithTimeout(100, handler: nil)
-    }
-
-    private func innerClear(history: BrowserHistory, callback: (s: Bool) -> Void) {
-        history.clearHistory().upon { callback(s: $0.isSuccess) }
-    }
-
-    private func clear(history: BrowserHistory, s: Bool = true) {
-        let expectation = self.expectationWithDescription("Wait for history")
-
-        innerClear(history) { success in
-            XCTAssertEqual(s, success, "Sites cleared")
-            expectation.fulfill()
-        }
-
-        self.waitForExpectationsWithTimeout(100, handler: nil)
+                XCTAssertNotNil(title, "Found right URL.")
+                XCTAssertEqual(s.title, title!, "Found right title.")
+            }
+        } else {
+            XCTFail("Couldn't get cursor.")
+        }
+    }
+
+    private func clear(history: BrowserHistory) {
+        XCTAssertTrue(history.clearHistory().value.isSuccess, "History cleared.")
     }
 
     private func checkVisits(history: BrowserHistory, url: String) {

            }
            cb()
        default:
            innerClear(history) { success in cb() }
        }
    }


import Storage

class TestHistory : ProfileTest {
    private func addSite(history: BrowserHistory, url: String, title: String, s: Bool = true) {
        let site = Site(url: url, title: title)
        let visit = SiteVisit(site: site, date: NSDate.nowMicroseconds())
        XCTAssertEqual(s, history.addLocalVisit(visit).value.isSuccess, "Site added: \(url).")
    }

    private func innerCheckSites(history: BrowserHistory, callback: (cursor: Cursor<Site>) -> Void) {
