Encapsulated MetaData members. Added helper functions for common tasks.

Only the test fixture `DirectoryTest` needed to modify this field (`directory_id()`). I removed the mutable return version, and made `DirectoryTest` a friend of MetaData.

Currently `data_map()` still needs to be mutable - several places modify its members directly.