fixed test classes; fixed thread safety for assigning IDs to instances