Updated test case to send a response, refactored the QEventLoop wait to a spin function