Added tests, removed some non essential code