Refactored setting the host from two separate mechanisms to one, because it runs for both real and mock in a near-similar manner