Your problem is caused by the "="-char in your /set -k command. While the use of "=" is recommended for /var commands, it's not part of the /set -syntax (...a common pitfall).
By setting your variable to the literal value "
= 2", the condition of your while statement isn't met any more and the loop stops at "= 2".

set -su30 %test123 1
while (5 >= %test123) {
set -sk %test123 $calc(%test123 + 1)
}
Note the -s switches (useful for debugging).