refactoring code to make it more reusable
contining refactor
finished refactor,tests pass.I probably should file the 'account enpoint returns success for blank bug' at some point.