Added test cases.
Improved TargetRef creation for existing targets.

If a target was created by another project, now the created targetref will contain a project reference.