Move utility function out of test file
Rewrite the moves function for clarity