Merge pull request #22 from christav/master

Refactorings and better tests