Added tests and solutions
Refactor code