Fixes for ksh tests, mostly working.

ksh has some issues with return codes and pipes, this commit
addresses a couple of them and tests shouldn't hang now