Fix a bug HistoryEntry.trim when the list of values is empty.  If max duration is > 0 this would fail trying to access the first element of an empty list.  Includes a test case to verify the fix.  Also adds additional argument checking to the HistoryLimit constructor to prevent similar defects.