test_p2p and associated fixes