Added tests for constraints. Cleaned up API for index.