Test generation and automatic correction