[XAPID-1037] refactor and add tests
6 files changed