radio: refactoring + add some tests