refactored app service and oauth with unit testing