Fix minor issuses; Move all util functions to util.lua.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>