         XCTAssertEqual(header.frame.height, 250)
         
         let collectionView = XCUIApplication().collectionViews.element(boundBy: 0)
-        execute(block: {
+        execute(until: header, hasHeight: 64) {
             collectionView.swipeUp()
-        }, until: header, hasHeight: 64)
+        }
     }
     
     func testCollectionViewContentInsetEqualToHeaderHeight() {

        XCUIApplication().collectionViews.staticTexts["Sticky header"].tap()
    }

    private func execute(block:() -> Void, until header:XCUIElement, hasHeight expectedHeight:CGFloat) {
        var numberOfSwipes = 0

        // Perform the block until the header is the expected height

        XCTAssertTrue(header.exists)
        
        // Go to the top of the view and make sure that the header is now uncollapsed
        execute(until: header, hasHeight: 250) {
            collectionView.swipeDown()
        }
    }
    
    // MARK: - Utilities
