refactor and implement missing tests