t: reduce direct access to repository internals via the filesystem
This MR contains some preliminary refactorings to reduce direct access to repository internals via the filesystem. The main motivation for this change is to make these tests compatible with a future alternative implementation of a reference database.
Part of &11655 (closed).