Fix building tests.

Prior to this commit, test drivers weren't specifying the correct ldflags to
link properly.
Introduce 'runtests' subcommand.