NXIO-158: refactor and fix tests