CMakeLists: add tests and move logic to src folder