Factor out the generation of token_keys to a separate routine, called from each test case. And make sure we remove the mkdtemp()-created directory after we're finished with it.