fixed code smells and unit tests.