adds some tests
- refactored for encapsulation
- added code comments
- updated tests