refactored globalmin, passing tests, closes #1