Can't you set this MessageHandler into the app source code itself rather than having to do it in the test?

It will be more reliable this way.

These test are very time consuming and occasionally unreliable so we need to do as few things as possible during the actual test. If we can set the app up in Gaia then it will be more reliable when we actually need to run the test.