Wrote a couple of the stub attachment tests.

Started improving attachment handling in the persistence layer.