Add unit tests for transaction, cleanup self references