Make cmake targets for tests work so we're ready for pushing to the
buildbot.

Note that there are still many improvements that can be made, but we
can of course continue to do those iteratively after this work is merged.
Rename temppath -> tempdir for consistency with rootdir, filedir.

(Because I kept making the same typo and got annoyed).
Minor edits and comments.