unittest and minor fixes