refactoring client for better testability