rax modules: Perform region validation early

This pull request performs explicit region validation early, immediately after authenticating to attempt avoiding later errors that are not as easy to debug.

As a side effect, I also noticed duplicate lines to set the user agent, so the duplicate has been removed.