error in ol.format.KML and ol.format.GPX?

I have tried to export layers to these formats: 

* GeoJSON
* KML
* GPX

using 

    new ol.format

then

    writeFeatures(features)

This only works for me when I use GeoJSON.

With KML and GPX 'writeFeatures(features)' returns

    TypeError: undefined is not a function

See the demo: http://codepen.io/barbalex/pen/IDwrj (try setting the 'Data type' to 'KML')