refactor client & unit test