Safer build

When a build 500s at a certain point, it currently leaves a half-made build around that has caused a lot of confusion.

A bandaid fix might have been to save a "not-done" flag on that build and have it filtered out—but that would have just added to the code complexity. Instead I simplified the code somewhat by creating a `LazyAttachmentDoc` abstraction that lets you treat attachments like any other property instead of having to put them after saving.

Now, making a build should save exactly once, after the process has gone through; all attachments are then put immediately after saving.

This is my first PR that includes new tests in a LONG time. Maybe this can be the beginning of a beautiful pattern.

Depends upon the (already-merged) https://github.com/dimagi/dimagi-utils/blob/master/dimagi/utils/couch/lazy_attachment_doc.py (tests: https://github.com/dimagi/dimagi-utils/blob/master/dimagi/utils/tests/lazy_attachment_doc.py)