8-puzzle - Functions not working correctly

So, fix the ones that need fixing.
Until you do that, all bets about how code behaves are off.