add ClientTest, fix a few small bugs in Client class