bundle: fix wrong check of read_header()'s return value & add tests