Added more unit tests, squashed moar bugs