Improve setting of keywords and update tests