Adding a way to configure a scope to factory function

This code with a test helps solve the issue #26