Repeat email v1

Also adds some badly needed testing infrastructure.
Also, unique should not be here, but that's probably another bug.