 
             context("serial renew from same thread") {
 
-                it("should not renew the credentials after the previous renewal operation succeeded") {
-                    credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: IdToken, refreshToken: RefreshToken, expiresIn: Date(timeIntervalSinceNow: -ExpiresIn))
-                    _ = credentialsManager.store(credentials: credentials)
-                    stub(condition: isToken(Domain) && hasAtLeast(["refresh_token": RefreshToken])) { _ in
-                        return authResponse(accessToken: NewAccessToken, idToken: NewIdToken, refreshToken: NewRefreshToken, expiresIn: ExpiresIn)
-                    }
-                    waitUntil(timeout: Timeout) { done in
-                        credentialsManager.credentials { result in
-                            expect(result).to(haveCredentials())
-                        }
-                        credentialsManager.credentials { result in
-                            expect(result).to(beSuccessful())
-                            done()
-                        }
-                    }
-                }
-
                 it("should yield the stored credentials after the previous renewal operation succeeded") {
                     credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: IdToken, refreshToken: RefreshToken, expiresIn: Date(timeIntervalSinceNow: -ExpiresIn))
                     _ = credentialsManager.store(credentials: credentials)

            }

            context("serial renew from different threads") {

                it("should not renew the credentials after the previous renewal operation succeeded") {
                    credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: IdToken, refreshToken: RefreshToken, expiresIn: Date(timeIntervalSinceNow: -ExpiresIn))
                    _ = credentialsManager.store(credentials: credentials)
                    stub(condition: isToken(Domain) && hasAtLeast(["refresh_token": RefreshToken, "request": "first"])) { request in
                        return authResponse(accessToken: NewAccessToken, idToken: NewIdToken, refreshToken: NewRefreshToken, expiresIn: ExpiresIn)
                    }
                    waitUntil(timeout: Timeout) { done in
                        DispatchQueue.global(qos: .utility).sync {
                            credentialsManager.credentials(parameters: ["request": "first"]) { result in
                                expect(result).to(haveCredentials())
                            }
                        }
                        DispatchQueue.global(qos: .background).sync {
                            credentialsManager.credentials { result in
                                expect(result).to(beSuccessful())
                                done()
                            }
                        }
                    }
                }

                it("should yield the stored credentials after the previous renewal operation succeeded") {
                    credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: IdToken, refreshToken: RefreshToken, expiresIn: Date(timeIntervalSinceNow: -ExpiresIn))

                expect(credentialsManager.hasValid()).to(beFalse())
            }

            it("should have valid credentials when token valid") {
                let credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: IdToken, refreshToken: nil, expiresIn: Date(timeIntervalSinceNow: ExpiresIn))
                expect(credentialsManager.store(credentials: credentials)).to(beTrue())
                expect(credentialsManager.hasValid()).to(beTrue())
            }

            it("should not have valid credentials when token expired") {
                let credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: IdToken, refreshToken: nil, expiresIn: Date(timeIntervalSinceNow: -ExpiresIn))
                expect(credentialsManager.store(credentials: credentials)).to(beTrue())
                expect(credentialsManager.hasValid()).to(beFalse())
