AP_Mission: fixes to protect against endless loops
AP_Mission: tests added to example sketch