#9001 improve test isolation
Testing something that queries for _all_dbs is tricky as any dirt database left for debugging can cause the test to pass or fail at random. This changeset extracts list_db, restricts listing to the tested subset and some minor refactors.
Edited by Victor