For reasons that are beyond me, you may want to change all your tests from:

if test "$variable" = value ; then

to 

if test "x$variable" = "xyes" ; then

It has to do with some weird issue in shell which I can't remember at the moment.