RF: refactor fusing and add tests

Move fusing into main code, add tests