fixed some tests and conditions