Add debug infrastructure for tests