Add improvements and tests to ConnectionNegotiator