Refactor plan
Fix tests