refactor a little and add some skeleton tests