Improve error handling in test connection task
Store django secret key in environment variable