Fix minor issues and add tests for key handling

There are still issues with this code (starting with the name), but this is a start.

Tests are not built automatically, at least for now.
I'd prefer this to be moved inside the unix block, i.e.

<pre>unix {
    macx {
    } else {
    }
}</pre>