Add unit test and batch implementation