fixed quality issues.
added more unit tests for better coverage.