Unit tests and some additions to API

The unit tests are largely borrowed from the excellent pygeoip
module.