Extracted LazyFactory (closes #24)

By introducing LazyFactory, I made its 'caching' function more testable.
Merge pull request #33 from HippoPHP/reference_test

Extracted LazyFactory (closes #24)