started test suite, some batch read functions, some bugfixes

the test suite is set up to be isolated from postgres -- we monkey-patch
psycopg2 and log every interaction with it, then the tests largely
assert against the log.