Add tests, code documentation, refactoring.

any suggestions?
:+1: