Translated factory.d to factory.cpp
Added factory.hpp
Uncommented all tests from encode.cpp