Add unit tests for some common function