             }
             cb()
         default:
-            innerClear(history) { success in cb() }
+            history.clearHistory().upon() { success in cb() }
         }
     }
 



    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")

            for index in 0..<cursor.count {
                let s = cursor[index]!
                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)
    }

    private func checkVisits(history: BrowserHistory, url: String) {

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) {
