Fix error handling in shell command substitution

set -e has some mysterious effects with command substitutions.  It works
if the result is assigned to a variable, but not in some other
circumstances, especially in conditionals.  So fix this and add tests to
verify that the error handling works.
Quiet audit test output