CORE-5557: fixed some problems with the access token persistence code