Fix regex in purge, add a basic test