Using is_connected instead of num_test_p2p_connections ensures that python has taken notice that the p2p was disconnected.