tests: MSVC compat

MSVC doesn't like declaring variables in the middle of a block, so make
sure we only declare variables at the beginning of a block.