[PATCH v2 39/44] test: Move stat-printing into its own function