Continuing refactoring

* Merge from dev
* Misc. fixes to ProfileClient
* Added unit tests for ProfileClient
* Added mocks
This was just moved from a different project. I'm OK refactoring it later.