Add tests and fix logic for when apply_condition is output