Cleaned up X-Forwarded-Proto check, added tests