Filter refactored and test added to filter_fd