Removes unnecessary var declaration in end state test
Omits unnecessary if block in end state template