Fix resource counting bug with respond_to?(:length)

Fixes #263.

@arthurnn