Improvements to mediator and more tests.