try changing

echo 2 %test.%i

into

echo 2 %test. [ $+ [ %i ] ]