Fixed bug where a replaced selection could still be queried and attempted to be added to, also added tests for the situation