Add some more tests, code simplification