Handle Malformed URIs Bug

This is too complex. It either needs more documentation or it needs to be split up into several functions:
```python
def is_valid_uri(uri):
    def _has_valid_hostname(uri):
        try:
            hostname = urlparse(uri).hostname
            return is_private_ip_address(hostname) or IPy.IP(hostname)
        except ValueError as e:
            print 'Hostname is not correct in this URI: ', e
        return False

    def _has_valid_scheme(uri):
        return rfc3986.uri_reference(uri).scheme == u'tcp'

    return (
        uri is not None
        and rfc3986.is_valid_uri(                                                                                                                                       
            uri, 'utf-8' require_scheme=True, require_authority=True
        )
        and _has_valid_scheme(uri)
        and _has_valid_hostname(uri)
    )
```