Improve MockClient

If the connect condition variable has not been set by the time the
connection is accepted, wait until the variable has been set
Server only accept connections according to state