Adds support for localhost with a port

Includes test.