Make the access to register() synchronized

Otherwise, executing register on multiple threads can cause for things to get messy...

I had trouble with parallel tests registering their own objects and some simply not being registered. Works fine with this fix.