[PATCH v3 45/81] test: Tidy up sandbox handling in test-main