Fix a bug HistoryEntry.trim when the list of values is empty and max duration is > 0

This was throwing an exception when 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.