Start refactoring of keyword builder, starting with tests

Signed-off-by: Francis Galiegue <fgaliegue@gmail.com>