selftest.py: Move some infrastructure for running commands to selftest.run, with...