Added some basic tests and fixed a bug in which the Nth field of the header was aggregated into the following record in some cases.