Fixed module stuff so that it works in nodejs and and karma and added 2 more unit tests