Add specification test. Fix incorrect batch handling.