removed some spaces
better handling of exceptions and more unit tests