Fixing an NPE when cleaning up some test studies