Overhaul of the build system + added tests