refactored a bit, fixed up Makefile

refactoring wasn't necessary.  Hunting a bug down the wrong rabbit
hole.  Anyway, I found a minor bug by doing it (incorrect reference to a
variable out of scope)

big edits to Makefile.  Now in the future you can add tests by creating
a file "blahblah.md" and then the corresponding "blahblah.js" that tests
what you expect from the markdown.  The Makefile will spit out the tex,
then run the .js file, then clean the tex

as before can be run with npm test or make; make test; make clean