optimized factory and view helper, added unit tests