Directory client: Fixed the race conditions that happened when receiving a message from the Directory during the Register procedure