Exact diagonalization as impurity solver in dynamical mean field theory Applications to high temperature superconductors