Added lazy initialization for user agent.

This commit moves the logic for setting the user agent to the getter of the _userAgent_ property.