Meta-programming is never easy.
 - really fix #6, credits go to @zapnap
 - add unit tests