Fix host parsing

Sorry for the doubled pull-request. There were three errors happening:

1) I did not wrote a test for my change
2) I accidently reverted my first pr in my second one
3) parse_uri() fails to detect uri's like "example.com" as valid hosts and returns null instead. Therefor a seperate check is needed.

All three errors above are fixed within this pr.