Added factory and more tests