Removes useless test and unnecessary begin block