Simplified resolve() implementation. Added more test cases to it.