enforce async startup; refactor disconnect logic

This removes the somewhat messy mechanism for synchronised startup from the internals, favouring using e.g. message passing from the handler module to denote connection success.

Also a little refactoring, removing some overly verbose test output and moving the state functions to a more obvious place.

@inou can you tell me what you think of this?