Refactor bugscache tests & make them check the matched bug IDs (bug 1091579)

View the individual commits for cleaner diffs.