Updated core API.

- Added tests for everything
- Updated API to be much more flexible

Change-Id: I78b6e0b4f04ea9e319c68293837fbf45503c7d0a