Implemented more tests

- implemented more tests
- reduced code duplication