Add more tests and general readability improvements