Here's a small script I rewrote into GUI (to make it usable in normal editor) from MoCo works (it was originally written in vJass). If you use JNGP, I recommend use his
[vJASS] - [Snippet] Field of View (IsUnitInSight + IsUnitBehind) which is the original version I based the script from (it's quite easy to implement, just a line of custom script will do the job, and works much more efficiently).
It is able to detect if the unit is behind a unit.