More tests added and some refactorings are made