Refractored test 'statusListenerCalledOnConnecting()' to use states and wait for thread to execute or until timeout