Ensure keepalive flag is reset during connect for subsequent connections, plus tests. Should fix #21