added some unit tests for end of batch