[PATCH v6 08/19] test: Move the receive code into a function