refresh flow and test + test client refactoring