I applied a slightly different patch for enabling test mode from command line, enclosing the variable in double quotes - 4968e8994157f1152bf7461b16049d67e5c9cc59 .
For the bash related problems, I will open a dedicated issue on tracker to decide on a proper solution.