Extract api test resource clean up code