Added new tests.
Did refactoring.