Fix a bug in bamToFastq and add a test for it

See commit msg for more details.

Also added a couple of random nits, lmk if you want those as a separate PR!