fix bugs in tests and add new ones