Added transaction support and improved unit tests