Test establishing and closing a connection.