Adds more tests, fixes more bugs