added unit tests for exceptions, adjusted functions where necessary