apply mock cfg and cleanup afterward