Fixed device being disposed before main application had a chance to
cleanup controllers etc.
Fixed deadlock in unit tests.