Test and fix token expiry handling