Unit tests for APITest insert.
Various fixes & improvements.
Merge remote-tracking branch 'origin/back-end-working' into back-end-working