Adding tests, re-working the api a bit