Use one variable to track the connection state

Instead of using the negotiated and authenticated variable, the new
state variable of a connection is used. It can be atomically tested and
set. Fixes #11.