Idempotent tests

@joshmh this fixes and adds tests for idempotent send. It's a branch on top of `atm-protocol-merge` so that review is easier.