added some tests to check that removing parts of directories works as expected, and fixed some bugs related to it