First tests written. Multiple bugs fixed.