Added tests and bugfixes for removeResiduesFromChains