companion to #863, also cleans up some test memory issues