Add cppcheck linter to tests, fix the things it complains about

@sloppyfocus @eklitzke plz review kthx.