CORE-2002: added unit tests and fixes

This is a pull request containing unit tests and fixes for issue CORE-2002.
Please look at AbstractResourceAccessorTest.java for a better understanding of the problems solved by the fixes.