fixes #2421 added missing has_many :hostgroups and missing :dependent => destroy
fixes #2422 Rails 3.2: before_destroy / dependent => :destroy ordering
refs #2400 clean up tests so there are no orphaned foreign keys
fixes #2281 - don't allow admin flag to be removed from admin account