tests/db: Use transactions when inserting, updating or deleting data