https://jira.mongodb.org/browse/JAVA-863, fixed null checks in remove method