Add unit-tests and some implementation