Added unit and functional test. Still a lot is to be done.