a few tests and bug fixes