Avoid errors from previously faulty bounds check

Remove the check isntead and just catch the only possible exceptions.
This is more pythonic and avoids the need to worry about off-by-one
errors. Keep the greater than 0 check to prevent access by negative
numbers which while possible would look rather weird.

Change-Id: I31de64a746c5712d08a7c2ac1a14725989d2c7b4
Break query parsing out, add testing of it.

There have been a number of bugs in the match_parse_name function
in the past. While I believe that these are now fixed, there was
previously no automated testing of it. Breaking it out into its
own file significantly aids this.

Add testing of 'previous', 'current' and 'next{,+1,+2}' inputs for
a wide variety of apparent times. This feels like it provides good
coverage without going massively overboard.

Change-Id: Id66291035e9179acd65cedc8040fa88ac01686df