Fixes issue with SlaveIdGenerator and introduces tests for it

Introduces a bunch of tests for SlaveIdGenarator, verifying correct operation.
Fixes bug which might lead to loss of data from a race between transaction
 application and id allocation.
Small touchups of the code in IdGeneratorImpl