Adding unit test to write factory