Ensure attachment dat is replaced, not updated
Rework tests for clarity and better coverage