Split out the tests in test_refcounting.cpp.

Along the way it became clear that certain mysterious segfaults occur
only when the instantiated program contains zero global variables.

Possibly this is due to some unintutive restriction on LLVM structure
layouts, or maybe there's just a bug with empty global lists.