Add even more unit tests for the API

This patch replaces the remaining TODOs in test/unit/api_spec.js with actual tests.