Remove bashisms and make tests pass

Please check carefully!
I am not the greatest sh/bash/zsh expert :)

The tests are now passing but testing is limited to the sh shell.
A possible improvement would be to run the tests on all the different shells?