Refactored take_by_pointer and added better testing