Feature/unit tests

- Many unit tests added
- some minor code changes
- Documentation added