implement transaction and tests