Explicitly call PyNumber_Long(). Provides proper support for ipaddress objects.

Add tests to exercise more code paths.
Improve coverage.
Clear some type comparison warnings.