Characterization of quantum dynamics using quantum error correction