WIP: refactoring & implementation, real tests (STOX-31)