[tests] don't use global QEventLoop in protocol_test

QEventLoop complains if it is constructed before QApplication,
and this may be involved in a hard-to-reproduce segfault in
initTestCase. Move it into the function that uses it.