Wrapped scan test into a separate function

Will be adding other stuff, so wrapping up scan