fixes all tests and fixes #395