restructure test to data/docs/query, etc.  Add lots of test cases, implement make-doc and fetch functions.