Fix memory leak in oid shortener tests

This reorganizes the oid shortener tests to factor out some common code and also to close a big memory leak.