finish forward algorithm, and unittest, benchmark.