Add tail tests and fix bugs. Remove redundant eunit tests.