BUG: Fix py3-incompatible parts of model and test_model