Add tests

Tests and some smaller changes