implement componentApi macro

with tests and some refactoring