Purename fixes and tests