Refactoring

* Doing some refactoring
* Writing additional tests