1086 unhandled object disposed exception

Fixes #1086.

The first commit is a fairly extensive tidy up of the two files which I needed to touch. If you'd rather not include this commit then I'm happy to remove it. Just let me know.

As you can see from the last commit, the change required to fix this issue is incredibly trivial so perhaps you'd rather this PR included just the test commit and green commit in isolation.

The exception message now reads:

> Failed to listen on prefix 'http://+:1234/base/' because it conflicts with an existing registration on the machine.