Proposed fix for #1280

This PR proposes a fix for #1280, and #1676.

It is not ready to be merged, as I need a few more tests. 

Input for tests are very welcome.
Not sure it would really make a difference here, as host names cannot contain special characters. But you are right it should be ToLowerInvarian(), and that is changed now.