Refactored test_client and test_server