       expect(creds.cacheId.calls.length).to.equal(0)
       expect(creds.getStorage('id')).to.exist
 
-    it 'clears cache if getOpenIdToken fails', ->
+    it 'does not clear cache if getOpenIdToken fails for authorized user', ->
       creds.setStorage('id', 'MYID')
       helpers.mockResponses [
         {data: {IdentityId: 'IDENTITY-ID'}, error: null},

    
    it 'should call clearCachedId if user is not authorized', ->
      clearCache = helpers.spyOn(creds,'clearCachedId')
      helpers.mockResponses [
        {data: null, error: {code: 'NotAuthorizedException'}}
      ]
      creds.clearIdOnNotAuthorized()
      expect(clearCache.calls.length).to.equal(1)
      
    it 'should not call clearCachedId if user is authorized', ->
      clearCache = helpers.spyOn(creds,'clearCachedId')
      helpers.mockResponses [
        {data: null, error: {code: ''}}
      ]
      creds.clearIdOnNotAuthorized()
      expect(clearCache.calls.length).to.equal(0)


  describe 'createClients', ->
    beforeEach -> setupCreds()

      ]
      creds.refresh (err) -> expect(err.message).to.equal('INVALID SERVICE')
      expect(creds.cacheId.calls.length).to.equal(0)
      expect(creds.getStorage('id')).to.equal('MYID')

    it 'does try to load creds second time if service request failed', ->
      reqs = helpers.mockResponses [
