Create library to enable unit testing, refactor CMakeLists a bit

Change-Id: Iea9dd766098ff62bc7883945b1250682773775e7