Fixes for purging, and more tests