Additional tests and bug fixes