fix transaction bug; add test for transaction handling