Fixed waiting for the messages in the MessageListener test