Fix several issues in tests