Added purge function with appropriate test