Use a custom event and use a timeout to avoid waiting forever

When there is some test issue or thread issue its better to not
wait forever and lock up the whole problem but instead we should
just wait for a reasonable amount of time and then fail.