[PATCH v2 32/43] test: Move the receive code into a function