tests and error handling for elementwise logical operations