tests & refactor