Add tests for database state after attachment manipulation