add maxminddb support (bug 984606)

also reorganized the code to test with less mocks.