Complete basic tests and fix minor bugs