[WIP] Input validation refactoring

Refactor input validation to make it more consistent.

Todo
* [ ] Tests
* [x] docstrings
to make the code more readable. I could also put it into the check_array function.