Improve tests for generate_token