Test database storage and loading

* Fix bug in RepoState unmarshalling by adding UnmarshalJSON method
* Improve test coverage on flush() and close() methods
Fix bug in SearchResponse NumLinesMatched counting

* Previously the number of lines matched reported from a search was wildly
  inaccurate. It's now accurate.

* Pick a protocol unspecific name for our service errors.