some tests and bug fixes