Add resolve() method. Refactor. Add test cases