tests: add logic and tests