compiler: do not optimize Name + cleanup + unit test

The optimization is wrong; they can't have side effects, but they can
raise errors.

 + code cleanup
 + one test for fn functions