Fix obvious resource leak in tests, tightened up resource cleanup in backend decoder.