MediaEngineTests: fix race conditions in test for bgo#722731

Cherry-picked two commits from master:
- https://git.gnome.org/browse/banshee/commit/?id=109459ec8adcf745dfc81c60c47e911a09255ca2
- https://git.gnome.org/browse/banshee/commit/?id=17b119f4ce26ce6e5413a0e86d3b69147747211f

It's important to backport these because I'm going to commit
(and backport) subsequent fixes which require this test to be
working properly.