Rewrite shell(), various other stuff

Hmm - shell was over complex. Simplify it (using the support_for_tests
function as a model).
Control what is exported, and use external "shell"

Since we expect people to do:

  from support_for_tests import *

make that "*" more controlled!
Consequent tidying up

(now that support_for_tests is not polluting the namespaces)