move all credential caching code here
reorder tests to avoid test collision