[refactor] Pull common method in new class.
Unit test CookieService.