Added new tests
Minor refactoring