Improve test framework: fix Mac OS X bugs

Mac OS X sort(1) does not support -V (version number compare), and sed(1) does
not support the \+ regex operator.