Correct TCG->TDB conversion; add regression tests