Dumb fix for all the tests.

The problem was that when the widget was returned, it was still busy
rendering the DOM, so some of the scripts weren't loaded when we
requested them.

The current fix simply waits until the DOM is ready (by listening to
the loadFinished signal) and returns the widget only when it is
ready to be used.

This is a dumb fix because it is very intensive on the CPU. We need to
replace the waiting condition with a local event loop.