fix _get_or_create

This code queried for the instance using the key returned by `_primary_key_name`. That function however only returns the *first* primary key. And it may be that several primary keys are needed to uniquely identify a row, so it wasn't guaranteed to always get the correct row.

It also did not check whether the result of `_get_by` returned `None`, in which case it would go on to assign attributes to `None` rather than a model object.
Merge pull request #178 from goodscloud/fix_get_or_create

fix _get_or_create
Code style fixes.
Fixes duplicate test function name.
Merge branch 'master' of ssh://github.com/jfinkels/flask-restless
Style fixes.
Uses ternary conditional operator now in session_query().
Moves many helper functions from views.py to helpers.py.
Makes get_or_create() more readable (by humans).
Merge branch 'modelhelpers' of ssh://github.com/jfinkels/flask-restless into modelhelpers

Conflicts:
	flask_restless/helpers.py
	tests/test_helpers.py