Improved user API Key generation and added tests