Added new tests and divided logic