use an atomically accessed int variable instead of pthread_cancel()

to stop both the evictor and the expirer threads
don't rely on 'localhost' being set when running the unit tests