Added tests and better source tree organization