Added some unit tests for factory