[PATCH v5 09/20] test: Move the receive code into a function