Fixed transaction code.
Add test functionality.