tests: silence cppcheck unreadVariable and variableScope warnings

I have found that fixing the trivial warnings makes cppcheck more likely to
find real issues.