Pr/34 - from pull request #34

Takes changes from pull request #34 and adds tests. Also models setHostname more closely with setPort