clean up
refactor and integration tests