copied over implementation and tests from harmony-reflect