fixed the onMainStart behaviour so that event handlers that are undefined become function stubs and updated tests