Fixed bugs in Unit tests