Add tests
All tests pass. Fixes #9, #10, #11, #12