repair test and clean up ecr function