Add even more unit tests for the API

This patch replaces most of the remaining TODOs in test/unit/api_spec.js with actual tests.
Merge pull request #5174 from Snuffleupagus/even-more-api-unittests

Add even more unit tests for the API