helper function for magnitude/phase separation
added a unit test for magphase