Merge pull request #376 from elasticsales/master

Fix for #375 - toJSON should include IDs of unregistered models
Fix some code style; add a test for #407