add tests for dbcore

Based on the old migration tests for Library.
give test_db a better name: test_library
dbcore: terminology

Replace "library" and "lib" references in dbcore with "database" and "db" for
short.
a bit more dbcore testing