Improve the way tests are run

Tests are now only run when `make tests` is executed. The old behavior of running the tests can be restored by running cmake with `cmake -Dtest=ON ..`.