Adding tests and fixing the broken ones