Unit tests to cover all the branches in factory code