Move consumeSlow() under test utils

Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> (github: tonistiigi)
Generalize consumeSlow and add stop support

Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> (github: tonistiigi)
Fix panic on slow log consumer.

Fixes #8832

All stdio streams need to finish writing before the
connection can be closed.

Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> (github: tonistiigi)
Merge pull request #8866 from tonistiigi/fix-8832-logs-panic

Fix panic on slow log consumer.