adding unit test && minor improvements