tests: move code to run tests under bash into a helper library