[PATCH v7 4/8] test: Move the receive code into a function