I came across this when working on #2009670: Replace theme() with drupal_render() in simpletest module. The issue is described here but it also applies to Drupal 7.
Essentially, the class name for both 'expanded' and 'collapsed' states is 'simpletest-collapse'. While this is necessary given the styles, it can lead to confusion (as it happened in that thread). I am not sure if this is considered a frivolous change, but I am gonna try anyway. :)
I will attach the patch in comments.