Added getClientState() function
Fixed bugs with getClientState() and added tests for it