tests: make checkheads tests bash-compatible by avoiding `echo '\n'`

Using `echo` with escape codes is not portable, so this patch replaces
it by `printf`. I also changed several nearby lines to `printf` for
consistency.
7 jobs for topic/default/bash in 5 minutes and 19 seconds (queued for 2 seconds)
Status Name Job ID Coverage
  Test
passed doc #70112

00:00:16

passed flake8 #70106

00:00:26

manual pytype #70107
allowed to fail manual
passed tests-py2-cext #70108

00:04:31

passed tests-py2-pure #70109

00:05:15

passed tests-py3-cext #70110

00:05:19

passed tests-py3-pure #70111

00:02:43