add tests; rewrite pubmed tools; misc fixes