few tweaks and unit test