Started adding tests and already fixed a few bugs.