Extract TokenFileRegistry

It is used in tests to create and clean up token files.