This patch updates the shell scripts with some of the common best practices, which should make them more resilient to unusual failures and unexpected environments (in particular, directories with spaces). Most of these were identified by shellcheck.
For convenience, rename the directories so the order is explicit in the name. Make the simple test run first, to save time if it's not working.