tests: Use sed '$d' because head -n -1 is not portable

Fixes bug 726908