Adding tests and code for validPosition