Rename API functions and throw errors

I fixed up the message and improved the test.