Fix repeating loops

A lot of things changed here

* Set up rspec
* Added unit tests for most of the parsing functionality
* Added unit tests to narrow down the problematic behaviour that was preventing certain messages being parsed
* Added a functional test to parse a more substantial mixed document

In the end the problem was in the handling of repeated loops. After matching a segment or a loop, the code then tries to match another one with the `do_repeats` function, which basically just hands things off to `parse` and checks the result.

The problem was that requirements weren't being checked. A loop would pass if the first element matched even if the second didn't and it was required. This would cause the parser to eat up the first segment in the next loop (e.g. GS, which denotes a new group and is used everwhere), fail because the next segment didn't match, and then barf on the rest because there was no GS segment to start off.

The fix was to modify the loop parsing to only pass a loop of all the required elements were met and if not, to rewind back to where we started in the loop.