On scheduled tasks use task.due if present, otherwise use state_history timestamp #435

added test for preserving scheduled task due value.