Unit tests

Fixed some old unit tests and wrote some new ones. Also added TravisCI configuration.