Added initial version and tests.
Cleaned up issues pointed out by checkstyle and jshint