Kat test fixed

Bugs from Kat's test fixed