Added integration tests for referencing scripts functionality.
Merge from master