added integration test
refactoring