reorganized factories and added test file