adding unit tests.
code cleanup