Make temp attribute more solid and add unit test on regression

Signed-off-by: Julien Danjou <julien@danjou.info>
Implements defclass

This fixes issue #156

Signed-off-by: Julien Danjou <julien@danjou.info>