     
     it 'should call clearCachedId if user is not authorized', ->
       clearCache = helpers.spyOn(creds,'clearCachedId')
-      helpers.mockResponses [
-        {data: null, error: {code: 'NotAuthorizedException'}}
-      ]
-      creds.clearIdOnNotAuthorized()
+      idErr = {code: 'NotAuthorizedException'}
+      creds.clearIdOnNotAuthorized(idErr)
       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()
+      idErr = {code: 'TEST'}
+      creds.clearIdOnNotAuthorized(idErr)
       expect(clearCache.calls.length).to.equal(0)
-
 
   describe 'createClients', ->
     beforeEach -> setupCreds()

      expect(creds.cacheId.calls.length).to.equal(0)
      expect(creds.getStorage('id')).to.exist

    it 'clears cache if getOpenIdToken fails', ->
      creds.setStorage('id', 'MYID')
      helpers.mockResponses [
        {data: {IdentityId: 'IDENTITY-ID'}, error: null},

      expect(creds.cacheId.calls.length).to.equal(0)
      expect(creds.getStorage('id')).not.to.exist

    it 'does not clear cache if getId fails for authorized user', ->
      creds.setStorage('id', 'MYID')
      helpers.mockResponses [
        {data: {IdentityId: 'IDENTITY-ID'}, error: null},
