Refactor blob of code for finding min over all k into function.
Move asserts into test file.