[PATCH v4 33/46] test: Tidy up sandbox handling in test-main