Improved FSM generator for input sequences

Input sequences will now reset when the input is too slow (timeout is a
new template parameter) or incorrect.