Add tests, code documentation, refactoring.

any suggestions?
nice! :+1: