Replace deprecated ereg_replace
Fix unreliable test for the command line