simpler impl of withTrailing()/withLeading()
fix tests