Fixed issue with detecting which port to use.
- Always use the default port if the host header exists but there's no
  port.

#1363
Fixed casing in tests.