you likely need to reopen console (CONOUT$) attached to cmd.exe not the current output handle
as the MODE command deals with device, this command likely starts by opening the corresponding device (console, lpt serial line...)
for the tests, beware that cmd.exe output are localized so comparing command's output will not work
but you could (as tests):
* add a test for a non existent device * add a test for a non conforming CON configuration * try changing lines & columns and check in 'MODE CON:' output that the numerical values are present in output (findstr)
and put the tests dealing with errorlevel and return code in the relevant part of both test_builtins.cmd and test_builtins.bat
(more functional testing, like actually changing the screen buffer size, could go elsewhere only in the .cmd tests file)
in the code, from the behavior of lots of other builtin commands, it's very unlikely that the errorlevel is set with GetLastError()