Make modules static libraries

This PR reorganized the build environmane,t which brings many advantages, e.g. easier creation of tests and faster incremental builds.
Me two!