 
         var value = 0
 
-        DispatchQueue.global().async {
+        let sleepThenSetValueTo: (Int) -> () = { newValue in
             Thread.sleep(forTimeInterval: 1.1)
-            value = 1
+            value = newValue
+        }
+
+        var asyncOperation: () -> () = { sleepThenSetValueTo(1) }
+
+        if #available(OSX 10.10, *) {
+            DispatchQueue.global().async(execute: asyncOperation)
+        } else {
+            DispatchQueue.global(priority: .high).async(execute: asyncOperation)
         }
         expect { value }.toEventually(equal(1))
 
-        DispatchQueue.global().async {
-            Thread.sleep(forTimeInterval: 1.1)
-            value = 0
+        asyncOperation = { sleepThenSetValueTo(0) }
+
+        if #available(OSX 10.10, *) {
+            DispatchQueue.global().async(execute: asyncOperation)
+        } else {
+            DispatchQueue.global(priority: .high).async(execute: asyncOperation)
         }
         expect { value }.toEventuallyNot(equal(1))
     }

    func testWaitUntilMustBeInMainThread() {
#if !SWIFT_PACKAGE
        var executedAsyncBlock: Bool = false
        DispatchQueue.global().async {
            expect {
                waitUntil { done in done() }
            }.to(raiseException(named: "InvalidNimbleAPIUsage"))
            executedAsyncBlock = true
        }
        expect(executedAsyncBlock).toEventually(beTruthy())
#endif
    }

    func testToEventuallyMustBeInMainThread() {
#if !SWIFT_PACKAGE
        var executedAsyncBlock: Bool = false
        let asyncOperation: () -> () = {
            expect {
                expect(1).toEventually(equal(2))
            }.to(raiseException(named: "InvalidNimbleAPIUsage"))
            executedAsyncBlock = true
        }
        if #available(OSX 10.10, *) {
            DispatchQueue.global().async(execute: asyncOperation)
        } else {
            DispatchQueue.global(priority: .default).async(execute: asyncOperation)
        }
        expect(executedAsyncBlock).toEventually(beTruthy())
#endif
    }
