add further tests, improve code quality and readability