Improved the solution for RF-13706 and created a unit test