Health Secretary Matt Hancock said it took time to build the capacity needed to test people being discharged from hospitals into care homes at the start of the pandemic.