Add a check clause to avoid resource cloning (issue #172)

- And add units tests to verify that it works as expected (issue #172)