Refs #8570. Add code for writing attributes and test for it.