Clean up maximum_k and test functions