[PATCH v4 09/19] test: Move the receive code into a function