Refactor + new tests