Add tests for accessor (and fix a bug).