tests and logic