Undefined index exception and test