Rebasing and adding tests