Fix tx logic in BerkeleyDB state manager