Clean up leaked memory in error state
- Also fix how riak_c_cunit runs only integration or unit tests