Add a MainLoop wrapper class

* MainLoop() from tools enable to handle the GLib mainloop
* Move the handy decorator to run a function in mainloop there
* Adapt and add tests for it.