Fix code & tests