Handle invalid task roots gracefully

If a root task was previously invalid, it would cause an NPE. Fix
this NPE and output an INVALID task when this happens instead.
Also, Add test case to validate the fix.

Change-Id: Ia3d61315880fd7ac4e50c45c26949c2ba9880de4
5 files changed