Hi Asaf,
I've tested the function and it is working as expected, basically if the user (in your case targetobject) is free for the entire period it return true otherwise false.
I suggest the following steps:
1. Narrow down the problem. Write a Custom Action a simple that checks the availability and make sure it works exactly as you would expect (e.g. CA on user object with startdate and enddate as variables - make sure you user GetStartWorkDay() and GetEndWorkDay() on the dates respectively).
2. Write the CA on WorkItem that instead of changing the units field you pop a notification (there's a a Notify action) - it will allow you to debug it better.
3. Write the WR after all the lessons learned from the previous examples.
If you still don't get the expected result, join one of our weekly Advanced Configuration Office Hours and one of our experts will love to assist.
Good luck!
Tamir