Manage tests with cmake, and make them parallelizable.

Resolves #219.