Improving approximate-optimized effective potentials by imposing exact conditions: Theory and applications to electronic statics and dynamics