Make io.BED a bit more robust and add tests.