hide empty groups in beautiful forms

fix calc for whether a group should be hidden
previous fix was overzealous (4b1478e)

fixes: http://manage.dimagi.com/default.asp?119523

second commit fixes a bug in the tests that was unrelated but definitely wrong.