[PATCH v5 31/44] test: Tidy up sandbox handling in test-main