Cleaned up API a bit and added a test