allow to set an expiration time for the temporary test keys eventually created

and fixed some leaks as well