Fix NullPointerException
Add 401 authenticate challenge
Allow autologin in TESTING env