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.