Move on_incoming_packets, batching and its auxiliar functions to community.py

Also remove obsoleted tests.