Cleaning CMake stuff; add make test target for testing of the examples
Fixing the error handling in the examples