Use qc::qp_encode, fix tests